<html>
<head><meta charset="utf-8"><title>Option&lt;Crate&gt; · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html">Option&lt;Crate&gt;</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="220238605"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220238605" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220238605">(Dec 17 2020 at 12:49)</a>:</h4>
<p>I noticed that almost all types in <code>code_model.rs</code> have a <code>pub fn krate(self, db: &amp;dyn HirDatabase) -&gt; Option&lt;Crate&gt;</code> that always returns <code>Some</code>. Is there a reason for that or can I change it to return just <code>Crate</code>?</p>



<a name="220238898"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220238898" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220238898">(Dec 17 2020 at 12:52)</a>:</h4>
<p>I <em>think</em> primitives are not associated with any crate</p>



<a name="220238934"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220238934" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220238934">(Dec 17 2020 at 12:52)</a>:</h4>
<p>but yeah, they probably should refer to a specific crate</p>



<a name="220238980"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220238980" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220238980">(Dec 17 2020 at 12:53)</a>:</h4>
<p>OTOH, I am not sure it's such a good idea to have <em>every</em> type implement <code>fn module</code>, <code>fn crate</code></p>



<a name="220239000"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220239000" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220239000">(Dec 17 2020 at 12:53)</a>:</h4>
<p>This feels like a missing abstraction somewhere</p>



<a name="220239015"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220239015" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220239015">(Dec 17 2020 at 12:53)</a>:</h4>
<p>Hmm, interestingly a lot of types have a <code>fn module(self, db: &amp;dyn HirDatabase) -&gt; Module</code>, which then <em>does</em> allow you to get the defining crate anyways</p>



<a name="220239034"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220239034" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220239034">(Dec 17 2020 at 12:53)</a>:</h4>
<p>The hir_def crate has <code>HasModule</code></p>



<a name="220239093"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220239093" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220239093">(Dec 17 2020 at 12:54)</a>:</h4>
<p>Which could have a provided method that returns the crate</p>



<a name="220239780"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220239780" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220239780">(Dec 17 2020 at 13:01)</a>:</h4>
<p>Ok, I think I've recalled historical context here</p>



<a name="220239804"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220239804" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220239804">(Dec 17 2020 at 13:01)</a>:</h4>
<p>Originally, defs were very tightly bounded to AST</p>



<a name="220239833"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220239833" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220239833">(Dec 17 2020 at 13:01)</a>:</h4>
<p>Basically, there was an <code>fn to_def(ast: ast::Struct) -&gt; hir::Struct</code>.</p>



<a name="220239840"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220239840" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220239840">(Dec 17 2020 at 13:01)</a>:</h4>
<p>Not how it was infailable.</p>



<a name="220239923"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220239923" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220239923">(Dec 17 2020 at 13:02)</a>:</h4>
<p>The idea was that you can create <code>hir</code> even for files which are not otherwise linked with the build process</p>



<a name="220239962"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220239962" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220239962">(Dec 17 2020 at 13:02)</a>:</h4>
<p>Since we've made ast-&gt;hir conversion failable, now we should assume that the crate always exists</p>



<a name="220239999"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220239999" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220239999">(Dec 17 2020 at 13:03)</a>:</h4>
<p>so, <span class="user-mention" data-user-id="211727">@Jonas Schievink</span> , I think we should make everything return a non-None crate, modulo potential primite bug</p>



<a name="220240035"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220240035" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220240035">(Dec 17 2020 at 13:03)</a>:</h4>
<p>But also, <em>maybe</em> we should only have <code>fn module</code> and use two calls for crate?</p>



<a name="220240080"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220240080" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220240080">(Dec 17 2020 at 13:03)</a>:</h4>
<p>Interesting, thanks for the recap!</p>



<a name="220240135"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220240135" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220240135">(Dec 17 2020 at 13:04)</a>:</h4>
<p>I kinda want a trait for this, since that would help with making <code>HasAttrs</code> work with <code>cfg_attr</code></p>



<a name="220240172"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220240172" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220240172">(Dec 17 2020 at 13:04)</a>:</h4>
<p>(the crate needs to be known to access attributes once we handle them)</p>



<a name="220240346"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220240346" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220240346">(Dec 17 2020 at 13:06)</a>:</h4>
<p>Hmm, we have 2 <code>HasSource</code> traits already, so I guess it wouldn't be the end of the world to define another <code>HasModule</code> trait in <code>hir</code></p>



<a name="220240620"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220240620" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220240620">(Dec 17 2020 at 13:09)</a>:</h4>
<p>Yeah, we def should do <em>something</em> here, good catch about uselss option</p>



<a name="220240679"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220240679" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220240679">(Dec 17 2020 at 13:10)</a>:</h4>
<p>I am not so sure about a trait though. I think we never actually use this in generic context</p>



<a name="220240694"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220240694" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220240694">(Dec 17 2020 at 13:10)</a>:</h4>
<p>So, having inherent method would work better.</p>



<a name="220240717"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220240717" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220240717">(Dec 17 2020 at 13:10)</a>:</h4>
<p>I actually want to provide inherent impls for all of the <code>ast</code> traits as well, so that you don't have to import them</p>



<a name="220240729"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220240729" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220240729">(Dec 17 2020 at 13:10)</a>:</h4>
<p>(they trait would still be there for cases where you do want to handle stuff generically)</p>



<a name="220240763"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220240763" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220240763">(Dec 17 2020 at 13:11)</a>:</h4>
<p><a href="https://matklad.github.io/2020/08/15/concrete-abstraction.html">https://matklad.github.io/2020/08/15/concrete-abstraction.html</a></p>



<a name="220240994"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220240994" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220240994">(Dec 17 2020 at 13:13)</a>:</h4>
<p>Problem is that <code>HasAttrs</code> <em>is</em> used generically, and to access the attributes once we handle <code>cfg_attr</code>, you need the <code>CrateId</code> (not just <code>Crate</code>)... so, not yet sure how to handle this</p>



<a name="220241593"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220241593" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220241593">(Dec 17 2020 at 13:18)</a>:</h4>
<p>Hm, you'll need CrateId <em>inside</em> <code>HasAttrs</code> impl, right?</p>



<a name="220241604"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220241604" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220241604">(Dec 17 2020 at 13:18)</a>:</h4>
<p>not outside?</p>



<a name="220241637"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220241637" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220241637">(Dec 17 2020 at 13:18)</a>:</h4>
<p>I think I <em>could</em> make it work that way</p>



<a name="220241702"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220241702" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220241702">(Dec 17 2020 at 13:19)</a>:</h4>
<p>I think you need <code>fn crate(def: AttrDefId) -&gt; CrateId</code></p>



<a name="220241715"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220241715" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220241715">(Dec 17 2020 at 13:19)</a>:</h4>
<p>And that can be implemented in <code>hir_def</code></p>



<a name="220241730"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220241730" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220241730">(Dec 17 2020 at 13:19)</a>:</h4>
<p>What I have now is a method on <code>Attrs</code>: <code>fn query(&amp;self, db: &amp;dyn DefDatabase, krate: CrateId) -&gt; QueryableAttrs&lt;'_&gt;</code></p>
<p>Since this bororws <code>self</code>, there wouldn't be any way to return the <code>QueryableAttrs</code> to the caller.</p>



<a name="220241731"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220241731" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220241731">(Dec 17 2020 at 13:19)</a>:</h4>
<p>(but you obv have more context here than I do )</p>



<a name="220241761"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220241761" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220241761">(Dec 17 2020 at 13:19)</a>:</h4>
<p>Ahhh</p>



<a name="220241770"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220241770" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220241770">(Dec 17 2020 at 13:20)</a>:</h4>
<p>If I make <code>QueryableAttrs</code> owned, this could be made to work</p>



<a name="220241820"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220241820" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220241820">(Dec 17 2020 at 13:20)</a>:</h4>
<p>So you want to cfg-attr attributes lazily?</p>



<a name="220241837"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220241837" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220241837">(Dec 17 2020 at 13:20)</a>:</h4>
<p>At the point where we query them, not at the point of definition?</p>



<a name="220241842"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220241842" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220241842">(Dec 17 2020 at 13:20)</a>:</h4>
<p>Which just means cloning the <code>Attrs</code>, which shouldn't be too bad</p>



<a name="220241851"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220241851" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220241851">(Dec 17 2020 at 13:20)</a>:</h4>
<p>Yeah that was my plan</p>



<a name="220241859"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220241859" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220241859">(Dec 17 2020 at 13:20)</a>:</h4>
<p><span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span></p>



<a name="220241876"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220241876" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220241876">(Dec 17 2020 at 13:20)</a>:</h4>
<p>I briefly tried going the other way, but this seemed easier</p>



<a name="220241885"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220241885" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220241885">(Dec 17 2020 at 13:20)</a>:</h4>
<p>I would think that an easier model is that in which you only ever have active attributes</p>



<a name="220241898"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220241898" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220241898">(Dec 17 2020 at 13:21)</a>:</h4>
<p>though maybe that's not true</p>



<a name="220241901"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220241901" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220241901">(Dec 17 2020 at 13:21)</a>:</h4>
<p>I mean, an ieasier model to use</p>



<a name="220241910"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220241910" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220241910">(Dec 17 2020 at 13:21)</a>:</h4>
<p>not sure about implementation-side</p>



<a name="220241912"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220241912" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220241912">(Dec 17 2020 at 13:21)</a>:</h4>
<p>yeah</p>



<a name="220241959"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220241959" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220241959">(Dec 17 2020 at 13:21)</a>:</h4>
<p>but, as an assist author, I would prefer to be in a world where all "macros" are expanded, and where conditional compilation doesn't exist</p>



<a name="220242038"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220242038" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220242038">(Dec 17 2020 at 13:22)</a>:</h4>
<p>(unrelated, but I've realized that early handing of conditional compilation is a thing whcih makes prortability lints and unified std not implementable in a "reliable" way)</p>



<a name="220242043"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220242043" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220242043">(Dec 17 2020 at 13:22)</a>:</h4>
<p>mhmm, that's reasonable</p>



<a name="220243356"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220243356" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220243356">(Dec 17 2020 at 13:35)</a>:</h4>
<p>seems like there's a lot of calls to <code>Attrs::from_attrs_owner</code> inside the IDE crates that would somehow need the <code>CrateId</code></p>



<a name="220243390"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220243390" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220243390">(Dec 17 2020 at 13:35)</a>:</h4>
<p>maybe this is a larger-scale refactoring than I thought, and should be done in phases</p>



<a name="220243893"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220243893" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220243893">(Dec 17 2020 at 13:40)</a>:</h4>
<p>wait</p>



<a name="220243903"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220243903" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220243903">(Dec 17 2020 at 13:40)</a>:</h4>
<p>how</p>



<a name="220243958"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220243958" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220243958">(Dec 17 2020 at 13:40)</a>:</h4>
<p>that's wrong, IDE shouldn't call <code>from_attrs_owner</code></p>



<a name="220244074"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220244074" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220244074">(Dec 17 2020 at 13:41)</a>:</h4>
<p>Ook, I seee</p>



<a name="220244087"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220244087" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220244087">(Dec 17 2020 at 13:41)</a>:</h4>
<p>all thouse usages are wrong :D</p>



<a name="220244313"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220244313" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220244313">(Dec 17 2020 at 13:43)</a>:</h4>
<p>oh no :D</p>



<a name="220244376"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220244376" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220244376">(Dec 17 2020 at 13:44)</a>:</h4>
<p>(as a meta note: in <code>hir_(def|expand|ty)</code>  anything goes -- it's useful to keep abstraction thin and do whatever is the easiest to get the cake eaten. In hir, however, care must be taken to not expose impl detail. The latter is a futile battle and a whack-a-mole game, but we still need to fight it :-) )</p>



<a name="220244422"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220244422" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220244422">(Dec 17 2020 at 13:44)</a>:</h4>
<p>yeah, it's a bit odd that <code>Attrs</code> is just used all over the stack here</p>



<a name="220244459"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220244459" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220244459">(Dec 17 2020 at 13:45)</a>:</h4>
<p>I think there are only two usages though?</p>



<a name="220244478"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220244478" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220244478">(Dec 17 2020 at 13:45)</a>:</h4>
<p>One inside <code>nav_target</code>, to get docs from symbols from symbol index</p>



<a name="220244493"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220244493" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220244493">(Dec 17 2020 at 13:45)</a>:</h4>
<p>The second one inside runnables</p>



<a name="220244519"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220244519" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220244519">(Dec 17 2020 at 13:45)</a>:</h4>
<p>I am dealing with runnables due to an unrealted issue, I might be able to paper over that today</p>



<a name="220244592"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220244592" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220244592">(Dec 17 2020 at 13:46)</a>:</h4>
<p>THe one inside symbol index is interesting...</p>



<a name="220244648"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220244648" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220244648">(Dec 17 2020 at 13:47)</a>:</h4>
<p>Not sure what's the best solution there. Maybe just don't try to render docs for symbols from index? Not sure where they'd be visible in the UI</p>



<a name="220246094"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220246094" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220246094">(Dec 17 2020 at 14:01)</a>:</h4>
<p>Maybe this shows up on hover when the accurate resolution fails? Similar to the go to def fallback</p>



<a name="220246473"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220246473" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220246473">(Dec 17 2020 at 14:03)</a>:</h4>
<p>hmm, no, doesn't look like it; only the source preview works, not rendered documentation</p>



<a name="220251778"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220251778" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220251778">(Dec 17 2020 at 14:48)</a>:</h4>
<p>This PR makes <code>from_attrs_owner</code> private: <a href="https://github.com/rust-analyzer/rust-analyzer/pull/6916">https://github.com/rust-analyzer/rust-analyzer/pull/6916</a></p>



<a name="220252862"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220252862" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220252862">(Dec 17 2020 at 14:57)</a>:</h4>
<p>Since the ItemTree still stores attributes, I think we'll have to split them up into <code>RawAttrs</code>, which are crate-independent and do not handle <code>cfg_attr</code>, and <code>Attrs</code>, which were filtered according to the <code>cfg</code>s active for the crate in question.</p>



<a name="220252924"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220252924" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220252924">(Dec 17 2020 at 14:57)</a>:</h4>
<p>Since almost no attributes include <code>cfg_attr</code>, they can share the same data most of the time</p>



<a name="220252942"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220252942" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220252942">(Dec 17 2020 at 14:58)</a>:</h4>
<p>(sorry, just thinking out loud)</p>



<a name="220252991"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220252991" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220252991">(Dec 17 2020 at 14:58)</a>:</h4>
<p>Make sense</p>



<a name="220257545"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220257545" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220257545">(Dec 17 2020 at 15:31)</a>:</h4>
<p><span class="user-mention" data-user-id="211727">@Jonas Schievink</span> regarding doubts about overall <code>module/crate</code> API.</p>
<p>I am looking at the <code>ModuleDef::canonical_path</code> API right now, and it doesn't handle associated items propertly</p>



<a name="220257612"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220257612" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220257612">(Dec 17 2020 at 15:31)</a>:</h4>
<p>More generally, the problem with <code>.module</code> api is that the parent might actually be a block, and you might actually want to look at that, rather than at the module</p>



<a name="220257671"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220257671" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220257671">(Dec 17 2020 at 15:32)</a>:</h4>
<p>but with <code>.module</code> so easily accessible, it might not be obvious</p>



<a name="220257735"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220257735" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220257735">(Dec 17 2020 at 15:32)</a>:</h4>
<p>can associated items be <code>ModuleDef</code>s?</p>



<a name="220257758"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220257758" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220257758">(Dec 17 2020 at 15:32)</a>:</h4>
<p>I thought they had a separate type</p>



<a name="220257935"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220257935" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220257935">(Dec 17 2020 at 15:33)</a>:</h4>
<p>Sadly, the answer is "who knows" :(</p>



<a name="220257959"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220257959" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220257959">(Dec 17 2020 at 15:33)</a>:</h4>
<p>We do have <code>ModuleDef</code> and <code>AssocItemDef</code></p>



<a name="220258067"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220258067" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220258067">(Dec 17 2020 at 15:34)</a>:</h4>
<p>But I don't thing anything actually checks whether a thing is in module or an assoc item</p>



<a name="220258094"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220258094" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220258094">(Dec 17 2020 at 15:34)</a>:</h4>
<p>We <em>might</em> need to install such checks</p>



<a name="220258364"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220258364" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220258364">(Dec 17 2020 at 15:36)</a>:</h4>
<p>I think I wrote a comment about that somewhere <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="220258784"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220258784" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220258784">(Dec 17 2020 at 15:38)</a>:</h4>
<p>Also, calling <code>ModuleDef::module</code> on a module returns the module's <em>parent</em></p>



<a name="220258828"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220258828" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220258828">(Dec 17 2020 at 15:39)</a>:</h4>
<p>So perhaps it should be <code>containing_module</code> or something</p>



<a name="220258986"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220258986" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220258986">(Dec 17 2020 at 15:40)</a>:</h4>
<p>Maybe we need <code>Def::container</code> API which you can't get wrong</p>



<a name="220259036"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220259036" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220259036">(Dec 17 2020 at 15:40)</a>:</h4>
<p>And <code>Module::for_def(def: Def)</code>,  <code>Crate::for_def(def: Def)</code> as a more verbose error-prone version?</p>



<a name="220259083"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Option%3CCrate%3E/near/220259083" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Option.3CCrate.3E.html#220259083">(Dec 17 2020 at 15:41)</a>:</h4>
<p><span aria-label="black large square" class="emoji emoji-2b1b" role="img" title="black large square">:black_large_square:</span> Design <span aria-label="black large square" class="emoji emoji-2b1b" role="img" title="black large square">:black_large_square:</span></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>